const libK = require("../lib").libKDocsDrive;
const path = require("path");
const fs = require("fs")
let kdoc = new libK.KdocsDrive('V02SNBZCSU9maMmW4tEO-hLmiF6tL3000ad10efa0029d3cb62');

kdoc.ONLY_ONCE_getSpecialGroupInfo().then(async o => {
  let sp = o.data.special_group;
  let o_test = await sp.listDownloadableItemsInFolder();
  o_test = await sp.move_insideThisGroup([58923348838,58922229753],
    56270862007, 69967159822)
  debugger
  o_test = await sp.changeNameOf('56270862007', require("randomstring").generate({
    length: 900,
    charset:"我从哪里来"
  }))
  debugger
  let o_test1GBup = await sp.createFile_newfile(0, "1GB", "50634c9116dcb704d3ad06e1ac0787adb9987f87",
    "6d076b2df0355869ac5b1c0922d6ebf3");
  debugger
  o_test = await sp.getFileHistory(56033034460);
  o_test = await sp.app.getFirstVersionOf(56033034460)
  let o_testToken = await sp.getKs3Token()
  kdoc.axios.post(`https://wpsfile.ks3-cn-beijing.ksyun.com/${o_testToken.data.key}?uploads`, "", {
    headers: {
      Authorization: `KSS ${o_testToken.data.KSSAccessKeyId}:${o_testToken.data.Signature}`,
      "Content-Length": "0",
      Date: (new Date).toGMTString(),
      "x-kss-newfilename-in-body": "true",
      "x-kss-server-side-encryption": "AES256",
      policy: o_testToken.data.Policy
    },
    validateStatus: s => true
  }).then(axresp => {
    debugger
  })
  debugger
  o_test = await sp.getDownloadLink(o_test.data.files.filter(e => e.ftype == "file")[0].id)
  // o_test = await sp.uploadNewFileToFolder(`fs.createReadStream(
  //   path.join(__dirname,"../tmp/(C86) [甘味人形 (片桐ちさと)] 下克上しようとしたけど無理だったよ…。 (東方Project).zip.bt.xltd")
  // )`,"(C86) [甘味人形.docx");
  let wpslink = 'https://wpsfile.ksyun.com/55362e7e41640df36a4453f9df77e2b85f9a267f?response-content-disposition=attachment%3Bfilename%2A%3Dutf-8%27%27%2528C86%2529%2520%255B%25E7%2594%2598%25E5%2591%25B3%25E4%25BA%25BA%25E5%25BD%25A2.docx&KSSAccessKeyId=AKLTVHhAfrxsSC2bGR_WE8shnA&Expires=1572452236&Signature=GZjWrAa7juyi3%2FQfxNNHOuCGjk8%3D'
  kdoc.axios.get(wpslink, {
    headers: {
      referer: "https://www.qq.com",
    }
  }).then(axresp => {
    debugger
  }).catch(axerr => {
    debugger
  })
  debugger
})